﻿<%@ Page  UICulture="zh-CN" Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeBehind="AdmExchangeRate.aspx.cs" Inherits="FastShip88.Admin.AdmExchangeRate" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="server">
    <asp:Label ID="Label1" runat="server" Text="汇率为USD/CNY。系统计算时，会取最匹配的日期的汇率值。"></asp:Label>
    <hr />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1" AutoGenerateDeleteButton="True" 
        AutoGenerateEditButton="True" DataKeyNames="Id" DataMember="DefaultView" 
        EmptyDataText="没有汇率数据！" Width="380px" AllowPaging="True">
        <Columns>
            <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" 
                SortExpression="Id" Visible="False" ReadOnly="True" />
            <asp:BoundField DataField="Day" HeaderText="日期" SortExpression="Day" >
            </asp:BoundField>
            <asp:BoundField DataField="Rate" HeaderText="汇率" SortExpression="Rate" >
            </asp:BoundField>
        </Columns>
     
    </asp:GridView>
    <hr/>
    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="245px" 
        AutoGenerateRows="False" DataSourceID="SqlDataSource1" DefaultMode="Insert" 
        oniteminserted="DetailsView1_ItemInserted" DataKeyNames="Id">
        <Fields>
            <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" 
                SortExpression="Id" ReadOnly="True" />
            <asp:BoundField DataField="Day" HeaderText="日期" SortExpression="Day" />
            <asp:BoundField DataField="Rate" HeaderText="汇率" SortExpression="Rate" />
           
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
        ContextTypeName="FastShip88.DBAccess.UsersDataContext" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" OrderBy="Day desc" 
        TableName="ExchangeRates" AutoGenerateWhereClause="True">
    </asp:LinqDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:FastShip88ConnectionString %>" 
        DeleteCommand="DELETE FROM [ExchangeRates] WHERE [Id] = @Id" 
        InsertCommand="INSERT INTO [ExchangeRates] ([Day], [Rate]) VALUES (@Day, @Rate)" 
        SelectCommand="SELECT * FROM [ExchangeRates] ORDER BY [Day] DESC" 
        
        UpdateCommand="UPDATE [ExchangeRates] SET [Day] = @Day, [Rate] = @Rate WHERE [Id] = @Id">
        <DeleteParameters>
            <asp:Parameter Name="Id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter DbType="Date" Name="Day" />
            <asp:Parameter Name="Rate" Type="Double" />
            <asp:Parameter Name="Id" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter DbType="Date" Name="Day" />
            <asp:Parameter Name="Rate" Type="Double" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>
